package com.hotelvip.controller;


import com.hotelvip.common.utils.JSONResult;
import com.hotelvip.service.IdentityService;
import com.hotelvip.service.SysUserService;
import com.hotelvip.service.UserService;
import com.hotelvip.service.VipUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author:ypb
 * @Date:2021/1/20
 */
@RestController
@RequestMapping("/identity")
@Api(basePath = "/identity", tags = "查询介绍人信息")
public class IdentityController {

    @Autowired
    private IdentityService identityService;

    @Autowired
    private SysUserService sysUserService;

    @Autowired
    private UserService userService;

    /**
     * 此方法用于新增用户
     *
     * @return Identity
     */
/*
    @ApiOperation(value = "查询所有的介绍人身份的父类节点", httpMethod = "GET")
    @GetMapping("/getIdentityParent")
    public JSONResult getIdentityParent() {
        return JSONResult.ok(identityService.getIdentityParent());
    }*/

    /**
     * 通过介绍人身份id查询对应的介绍人
     *
     * @param index
     * @param index
     */

    @ApiOperation(value = "通过介绍人身份查询对应的介绍人", httpMethod = "GET")
    @GetMapping("/findIdentityByParentId")
    public JSONResult findIdentity(
            @ApiParam(value = "搜索关键字", required = false) @RequestParam(value = "key", required = false) String key,
            @ApiParam(value = "index", required = true) @RequestParam(value = "index", required = true) Integer index) {

        //查询员工
        return JSONResult.ok(userService.selectName(key,index));

    }

    /**
     * 新增必须是新增OTA类的介绍人信息
     * @param identity 介紹人信息
     * @return
     */
    @ApiOperation(value = "新增/修改OTA类介绍人", httpMethod = "POST")
    @PostMapping("/insertOrUpdateIdentities")
    public JSONResult insertIdentities(@RequestParam (value = "id", required = false) Long id,
                                       @RequestParam (value = "identity", required = true) String identity) {

        identityService.insertOrUpdateIdentities(id,identity);
        return JSONResult.ok();
    }

}
